package org.externalassets
{
	import flash.display.MovieClip;
	import flash.media.Sound;
	import flash.utils.getDefinitionByName;
	
	/**
	 * Static class used to return movieclips that are registered to the global class path.  
	 * Standard use is to load a swf using the AssetLoader to load a SWF that has classes that
	 * are linked, and register that swf to ApplicationDomain.CurrentDomain.  Once that registration
	 * has occured, the movieclips inside the swf will be accessible via these functions.
	 * 
	 * Note that if you send an incorrect name, these functions will all throw errors.
	 * 
	 * @author crebstock
	 */	
	public class AssetFinder
	{
		public static function FindMovieClipAsset( defName : String ) : MovieClip
		{
			var c : Class = Class( getDefinitionByName( defName ) );
			return new c();
		}
		
		public static function FindSoundAsset( defName : String ) : Sound
		{
			var c : Class = Class( getDefinitionByName( defName ) );
			return new c();
		}
		
		
		public static function FindObjectAsset( defName : String ) : Object
		{
			var c : Class = Class( getDefinitionByName( defName ) );
			return new c();
		}
		
		public function AssetFinder() { trace('Static Utility class should never, ever be initialized.'); }
	}
}